<?php
/**
 * I-Cafe framework
 * 
 * @category CF
 * @package CF_View
 * @link http://www.i-cafe.org
 * @license http://www.i-cafe.org/license
 * @version 04-04-2010
 * @author tcl_java@yahoo.com
 */

class CF_View_Basic extends CF_View_Abstract
{
	/**
	 * 
	 * @var string
	 */
	protected $_extension = 'phtml';
	/**
	 * @return string
	 */
	protected function _render()
	{
		extract($this->_vars);
		if($this->_resetOnRender) $this->_vars = array();
		
		ob_start();
		include func_get_arg(0);
		return ob_get_clean();
	}
	
	/**
	 * 
	 * @param string $file
	 * @param string $path
	 * @return string
	 */
	public function render($file = null, $path = null)
	{
		# fire before render event
		if(CF_Observable::VALUE_RETURN === $this->fireEvent('beforerender', array($this, &$file, &$path))) return;
		
		# render
		$res = $this->_render($this->getViewFile($file, $path));
		
		# fire render event
		$this->fireEvent('render', array($this, &$res, &$file, &$path)); 
		
		return $res;
	}
}